<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />

		<link rel="stylesheet" type="text/css" href="css/registLogin/util.css">
		<link rel="stylesheet" type="text/css" href="css/registLogin/main.css">
		<style>
			.area {
				margin: 20px auto 0px auto;
			}
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			.mui-input-group label {
				width: 22%;
			}
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
			}
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			.mui-content-padded {
				margin-top: 25px;
			}
			.mui-btn {
				padding: 10px;
			}
			.login100-form-btn{
				  font-family: Poppins-Medium;
				  font-size: 18px;
				  color: #fff;
				  line-height: 1.2;

				  justify-content: center;
				  align-items: center;
				  padding: 0 20px;
				  width: 100%;
				  height: 50px;
				  background-color: #57b846;
				  border-radius: 25px;

				  box-shadow: 0 10px 30px 0px rgba(87, 184, 70, 0.5);
				  -moz-box-shadow: 0 10px 30px 0px rgba(87, 184, 70, 0.5);
				  -webkit-box-shadow: 0 10px 30px 0px rgba(87, 184, 70, 0.5);
				  -o-box-shadow: 0 10px 30px 0px rgba(87, 184, 70, 0.5);
				  -ms-box-shadow: 0 10px 30px 0px rgba(87, 184, 70, 0.5);

				  -webkit-transition: all 0.4s;
				  -o-transition: all 0.4s;
				  -moz-transition: all 0.4s;
				  transition: all 0.4s;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">注册</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>账号</label>
					<input id='account' type="text" class="mui-input-clear mui-input" placeholder="请输入账号">
				</div>
				<div class="mui-input-row">
					<label>密码</label>
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
				</div>
				<div class="mui-input-row">
					<label>确认</label>
					<input id='password_confirm' type="password" class="mui-input-clear mui-input" placeholder="请确认密码">
				</div>
				<div class="mui-input-row">
					<label>手机</label>
					<input id='phone' type="phone" class="mui-input-clear mui-input" placeholder="请输入手机号码" style="margin-top: 9px;" pattern="^1[3-9]\d{9}$" required="" maxlength="11" />
				</div>
			</form>
			<div class="mui-input-row mui-checkbox mui-left">
				<label>我已同意<a href="agreement.html">用户协议</a></label>
				<input name="checkbox" value="Item 2" type="checkbox" checked>
			</div>
			<div class="mui-content-padded">
				<button id='reg' class="login100-form-btn">注册</button>
			</div>
			<div class="mui-content-padded">
				
			</div>
		</div>
		<script src="js/mui.js"></script>
		<script src="js/app.js"></script>
		<script src="js/app1.js"></script>
		<script>
			(function($, doc) {
				$.init();
				var checkPhone = function(phone) {
					phone = phone || '';
					var _phone=/^1[3-9]\d{9}$/;
					return (phone.length == 11&&(_phone.test(phone)));
				};
				mui('body').on('tap','a',function(){
					document.location.href=this.href;
				});
// 				var reg = function(regInfo, callback) {
// 					callback = callback || $.noop;
// 					regInfo = regInfo || {};
// 					regInfo.account = regInfo.account || '';
// 					regInfo.password = regInfo.password || '';
// 					if (regInfo.account.length < 5) {
// 						return callback('用户名最短需要 5 个字符');
// 					}
// 					if (regInfo.password.length < 6) {
// 						return callback('密码最短需要 6 个字符');
// 					}
// 					if (!checkPhone(regInfo.phone)) {
// 						return callback('手机号码不正确');
// 					}
// 					// 获取每台手机的唯一cid
// 					var cid = plus.push.getClientInfo().clientid;
// 					// 与后端联调
// 					console.log("regInfo.account.value=="+regInfo.account+"======"+regInfo.password.value+"======="+regInfo.phone.value+"=======");
// 					$.ajax("http://192.168.1.214:8080/user/register.action",{
// 						data:{
// 							username:regInfo.account,
// 							password:regInfo.password,
// 							phone:regInfo.phone,
// 							cid: cid
// 						},
// 						dataType:'json',//服务器返回json格式数据
// 						type:'post',//HTTP请求类型
// 						timeout:10000,//超时时间设置为10秒；
// 						headers:{'Content-Type':'application/json'},	              
// 						success:function(data){
// 							//服务器返回响应，根据响应结果，分析是否登录成功；
// 							console.log("服务器响应结果：=="+JSON.stringify(data));
// 								
// 							// if (data.status == 200) {
// 							if (data.code == 0) {
// 								console.log("执行到这里了111111");
// 								// 注册成功之后，保存全局用户对象到本地缓存
// 								var userInfoJson = data.msg;
// 								// console.log('data.data=========='+JSON.stringify(userInfoJson));
// 								window.app.setUserGlobalInfo(userInfoJson);
// 								
// 								// 页面跳转
// 								// $.openWindow("index.html", "index.html");
// 							} else {
// 								window.app.showToast(data.msg, "error");
// 								console.log("error");
// 							}
// 						}
// 					});
// 					return callback();
// 				};
				
				$.plusReady(function() {
					// alert("sslkajdlsjadlksajlkdjs")
					// var settings = app.getSettings();
					var regButton = doc.getElementById('reg');
					var accountBox = doc.getElementById('account');
					var passwordBox = doc.getElementById('password');
					var passwordConfirmBox = doc.getElementById('password_confirm');
					var phoneBox = doc.getElementById('phone');
					
					regButton.addEventListener('tap', function(event) {
						var regInfo = {
							account: accountBox.value,
							password: passwordBox.value,
							phone: phoneBox.value
						};
						var passwordConfirm = passwordConfirmBox.value;
						if (passwordConfirm != regInfo.password) {
							plus.nativeUI.toast('密码两次输入不一致');
							return;
						}
						
						app.reg(regInfo, function(err) {
							if (err) {
								plus.nativeUI.toast(err);
								return;
							}
							plus.nativeUI.toast('注册成功');
							/*
							 *启动页不是登录页，则需修改，使用mui.openWindow打开登录页面
							 */
// 							plus.webview.getLaunchWebview().show("pop-in",200,function () {
// 								plus.webview.currentWebview().close("none");
// 							});	
							//若启动页不是登录页，则需通过如下方式打开登录页
							$.back();
// 							$.openWindow({
// 								url: 'login.html',
// 								id: 'login.html',
// 								show: {
// 									aniShow: 'pop-in'
// 								}
// 							});
						});
						
					});
				});
			}(mui, document));
		</script>
	</body>

</html>